<template>
  <div class="ta-c">
    <span style="height: 34px;width: 36px;" @tap="onPicker"><i class="if icon-video" style="font-size: 21px;"></i></span>
    <div class="fs-xt">视频</div>
  </div>
</template>

<script>
export default {
  props: {
  },
  components: {
  },
  data () {
    return {
      tempFilePaths: []
    }
  },
  computed: {
  },
  watch: {
  },
  methods: {
    onPicker () {
      let that = this
      this.$emit('started', {type: 'video'})
      wx.chooseVideo({
        sourceType: ['album', 'camera'],
        camera: 'back',
        success: function(res) {
          let {width, height, duration, size, tempFilePath, thumbTempFilePath, errMsg} = res
          if (errMsg !== 'chooseVideo:ok') {
            wx.showModal({title: 'video select error!'})
            return
          }
          that.$emit('success', {type: 'video', path: tempFilePath, thumbTempFilePath, size, meta: {width, height, duration}})
        }
      })
    }
  }
}
</script>

<style scoped lang="less">
@import '../assets/less/var.less';
i {
  font-size: 2.6 * @baseSize;
  position: relative;
  top: 1px;
}
span {
  position: relative;
  top: 8px;
}
</style>
